<template>
  <div class="mv">
    <h4
      class="title"
      v-show="title">
      {{ title }}
    </h4>
    <div class="mv-simi">
      <div
        class="mv-recommend"
        v-for="item in mvs"
        :key="item.id">
        <el-image
          :src="item.image"
          lazy />
        <div
          @click="toMv(item.id)"
          class="mask">
          <span class="iconfont">&#xea82;</span>
        </div>
        <span
          class="playcount iconfont"
          v-if="item.playCount"
          >&#xe662; {{ (+item.playCount / 10000).toFixed(1) }}万</span
        >
        <span class="title-name">{{ item.name }}</span>
        <span class="singer">{{ item.artist }}</span>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { useRouter } from 'vue-router';
import { MV } from '../model';
import { getTheme } from '../utils/util';
import useConfigStore from '../store/config';

const config = useConfigStore();
//设置主题
const color = getTheme().get('fontColor');
const boxShadow = getTheme().get('shadow');

withDefaults(
  defineProps<{
    mvs?: MV[];
    title?: string;
  }>(),
  {
    title: '',
  }
);
const router = useRouter();
//点击推荐跳转
const toMv = (id: string) => {
  if (config.showScroll == 'block') {
    config.showScroll = 'none';
    config.left = '0px';
  }
  router.push({
    name: 'video',
    query: {
      id,
    },
  });
};
</script>

<style lang="less" scoped>
@font-color: v-bind(color);
@shadow: v-bind(boxShadow);
@font-color-gray: #7b7b7b;
@font-color-green: #1ed2a9;
@font-color-white: #ffffff;

.mv {
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;

  .title {
    font-weight: 520;
    font-size: 20px;
    letter-spacing: 1px;
    width: 81vw;
    color: @font-color;
    padding-left: 6.6px;
  }
  .mv-simi {
    width: 81vw;
    display: flex;
    flex-wrap: wrap;

    .mv-recommend {
      margin: 20px 6.6px 0;
      display: flex;
      flex-direction: column;
      position: relative;
      &:hover .el-image {
        transform: translateY(-5px);
      }
      &:hover .mask {
        opacity: 1;
        transform: translateY(-5px);
      }
      &:hover .playcount {
        opacity: 0;
      }
      .playcount {
        font-size: 12px;
        display: inline-block;
        text-align: center;
        line-height: 20px;
        height: 20px;
        min-width: 70px;
        padding: 0 5px;
        color: @font-color-white;
        background-color: rgba(0, 0, 0, 0.6);
        border-radius: 10px;
        position: absolute;
        top: 110px;
        right: 12px;
        cursor: pointer;
      }

      .mask {
        transition: 0.4s;
        width: 235px;
        height: 140px;
        background-color: rgba(0, 0, 0, 0.5);
        position: absolute;
        top: 0;
        border-radius: 10px;
        display: flex;
        justify-content: center;
        align-items: center;
        color: rgba(255, 255, 255, 0.4);
        opacity: 0;
        z-index: 10;
        span {
          font-size: 40px;
          transition: 0.4s;
          &:hover {
            color: @font-color-green;
          }
        }
      }
      .el-image {
        width: 235px;
        height: 140px;
        object-fit: cover;
        border-radius: 10px;
        box-shadow: @shadow;
        transition: 0.4s;
      }
      .title-name,
      .singer {
        display: block;
        font-size: 13px;
        width: 235px;
        margin-top: 10px;
        white-space: wrap;
        color: @font-color;
      }
      .singer {
        color: @font-color-gray;
        font-size: 12px;
        margin-top: 5px;
      }
    }
  }
}
</style>
